#include<stdio.h>
#include<unistd.h>
#include<sys/wait.h>
#include<stdlib.h>
#define NUM 16
int main(int argc,char* argv[],char* env[])
{
    pid_t id =fork();
    char* _env[NUM]={"MY_105=887755",NULL};
    if(id==0)
    {
        //子进程
       printf("子进程开始执行：\n");
       sleep(2);
       char* const _arg[NUM]={
          (char*) "ls",
          (char*) "-l",
          (char*) "-a",
          (char*)"-i",
           NULL
       };
       // execlp("python","python","test.py",NULL);
       // execv("/usr/bin/ls",_arg);
       // execl("./mycmd","mycmd","-b",NULL);
       // execvp("ls",_arg);
        execlp("ls","ls","-a","-l",NULL);
       // execl("/usr/bin/ls","ls","-a","-l",NULL);
       // execl("/usr/bin/top","top",NULL);    
      //  execle("./mycmd","mycmd","-a",NULL,env);
        exit(1);

    }
    else{
        int status=0;
        pid_t res=waitpid(-1,&status,0);
        if(id>0)
        {
            printf("wait success,exit code :%d\n",WEXITSTATUS(status));
        }
    }
    return 0;
}
